import { defineStore } from 'pinia'
import config from "@/config";
import tool from "@/utils/tool"
//TODO 先不要删除，将用到的地方逐一替换掉再删除
interface globalState {
	ismobile: boolean,
	layout: string,
	menuIsCollapse: boolean,
	layoutTags: boolean
}
export const useGlobalStore = defineStore('global', {
	state: (): globalState => ({
		//移动端布局
		ismobile: false,
		//布局
		layout: tool.data.get("APP_LAYOUT") || config.LAYOUT,
		//菜单是否折叠 toggle
		menuIsCollapse: tool.data.get("menuIsCollapse") || config.MENU_IS_COLLAPSE,
		//多标签栏
		layoutTags: tool.data.get("layoutTags") || config.LAYOUT_TAGS,
	}),
	getters: {
		GetIsmobile(): boolean {
			return this.ismobile;
		}
	},
	actions: {
		SET_ismobile(key: boolean) {
			this.ismobile = key
		},
		SET_layout(key: string) {
			this.layout = key
		},
		TOGGLE_menuIsCollapse(menuIsCollapse: boolean) {
			this.menuIsCollapse = menuIsCollapse
		},
		TOGGLE_layoutTags(layoutTags: boolean) {
			this.layoutTags = layoutTags
		}
	}
})